package org.wang.web.dao;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.jdbc.core.JdbcTemplate;
import org.wang.web.model.Person;

public class SpringJDBCSuperDaoImpl implements SpringJDBCSuperDao{

	private JdbcTemplate jdbcTemplate;
	
	public JdbcTemplate getJdbcTemplate() {
		return jdbcTemplate;
	}

	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}

	@SuppressWarnings("rawtypes")
	@Override
	public List<Person> getPersonList() {
		List<Person> list = new ArrayList<Person>();
		String sql = "SELECT * FROM user_tab";
		List listObj = jdbcTemplate.queryForList(sql);
		for(Object obj : listObj){
			if(obj instanceof Map){
				Map map = (Map)obj;
				Person p = new Person();
				p.setUserId((String)map.get("USERID"));
				p.setUserName((String)map.get("USERNAME"));
//				p.setAge(new Integer((String)map.get("AGE")));
				list.add(p);
			}
		}
		return list;
	}

	@Override
	public Person getPerson() {
	
		return null;
	}
	
}
